﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Ebada.Platform.Model;
using Ebada.UI.Base;
using Ebada.Client;
using Ebada.Core;
using Ebada.Client.Platform;
using System.Collections;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace Ebada.Modules.Vehicle
{
    /// <summary>
    /// 车辆登记编辑
    /// </summary>
    public partial class frmVehiclesSeletcter : FormBase{


        public frmVehiclesSeletcter()
        {
            InitializeComponent();
        }
        private void frmVehiclesEdit_Load(object sender, EventArgs e)
        {

           

        }
        public void initColumns()
        {
            for (int i = 0; i < gridView1.Columns.Count; i++)
            {
                gridView1.Columns[i].VisibleIndex = -1;
            }
            int m = 0;
            gridView1.Columns["VehicleCode"].Caption = "序号";
            gridView1.Columns["VehicleCode"].VisibleIndex = m++;
            gridView1.Columns["VehicleNumber"].Caption = "车牌号";
            gridView1.Columns["VehicleNumber"].VisibleIndex = m++;
            gridView1.Columns["EmployeeName"].Caption = "驾驶员";
            gridView1.Columns["EmployeeName"].VisibleIndex = m++;
            gridView1.Columns["VehicleType"].Caption = "车辆类型";
            gridView1.Columns["VehicleType"].VisibleIndex = m++;
            gridView1.Columns["OldVehicleNumber"].Caption = "原车牌号";
            gridView1.Columns["OldVehicleNumber"].VisibleIndex = m++;
            gridView1.Columns["UsageType"].Caption = "用途";
            gridView1.Columns["UsageType"].VisibleIndex = m++;
            gridView1.Columns["VehicleModel"].Caption = "车辆型号";
            gridView1.Columns["VehicleModel"].VisibleIndex = m++;
            gridView1.Columns["Tonnage"].Caption = "吨位及人数";
            gridView1.Columns["Tonnage"].VisibleIndex = m++;
            gridView1.Columns["RegDate"].Caption = "登记日期";
            gridView1.Columns["RegDate"].VisibleIndex = m++;
            gridView1.Columns["Color"].Caption = "颜色";
            gridView1.Columns["Color"].VisibleIndex = m++;
            gridView1.Columns["Brand"].Caption = "车辆品牌";
            gridView1.Columns["Brand"].VisibleIndex = m++;
            gridView1.Columns["PersonnelAllocationNum"].Caption = "定证编号";
            gridView1.Columns["PersonnelAllocationNum"].VisibleIndex = m++;
            gridView1.Columns["OrgName"].Caption = "车属单位";
            gridView1.Columns["OrgName"].VisibleIndex = m++;
            gridView1.Columns["UsingOrgName"].Caption = "使用单位";
            gridView1.Columns["UsingOrgName"].VisibleIndex = m++;
            gridView1.Columns["VINNum"].Caption = "识别码";
            gridView1.Columns["VINNum"].VisibleIndex = m++;
            gridView1.Columns["DocumentsNum"].Caption = "档案号";
            gridView1.Columns["DocumentsNum"].VisibleIndex = m++;
            gridView1.Columns["EngineNum"].Caption = "发动机号";
            gridView1.Columns["EngineNum"].VisibleIndex = m++;
            gridView1.Columns["PurchaseTax"].Caption = "购置税费";
            gridView1.Columns["PurchaseTax"].VisibleIndex = m++;
            gridView1.Columns["PurchaseDate"].Caption = "购买日期";
            gridView1.Columns["PurchaseDate"].VisibleIndex = m++;
            gridView1.Columns["AcquisitionPrice"].Caption = "购置价格";
            gridView1.Columns["AcquisitionPrice"].VisibleIndex = m++;
            gridView1.Columns["PurchasePrice"].Caption = "购车价";
            gridView1.Columns["PurchasePrice"].VisibleIndex = m++;
            gridView1.Columns["PurchaseTaxNum"].Caption = "购置税证号";
            gridView1.Columns["PurchaseTaxNum"].VisibleIndex = m++;
            gridView1.Columns["InsuranceOrgName"].Caption = "保险单位";
            gridView1.Columns["InsuranceOrgName"].VisibleIndex = m++;
            gridView1.Columns["InsurancePrice"].Caption = "保险金额";
            gridView1.Columns["InsurancePrice"].VisibleIndex = m++;
            gridView1.Columns["InsuranceStartDate"].Caption = "保险期从";
            gridView1.Columns["InsuranceStartDate"].VisibleIndex = m++;
            gridView1.Columns["InsuranceEndDate"].Caption = "保险期至";
            gridView1.Columns["InsuranceEndDate"].VisibleIndex = m++;
            gridView1.Columns["Remark"].Caption = "备注";
            gridView1.Columns["Remark"].VisibleIndex = m++;
        }
        public Vehicles SelectObj = new Vehicles();
        /// <summary>
        /// 查询条件
        /// </summary>
        /// <param name="sql_where"></param>
        public void InitData_Slect(string sql_where)
        {
            IList<Vehicles> vlist = MainHelper.GetSqlMap<Vehicles>().GetListByWhere<Vehicles>(sql_where);
            gridControl1.DataSource = vlist;
            initColumns();

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (gridView1.FocusedRowHandle < 0)
            {
                MessageBox.Show("无车辆信息！");
                return;
            }
            SelectObj = (Ebada.Platform.Model.Vehicles)(gridView1.GetFocusedRow());
            DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            SelectObj = this.gridView1.GetFocusedRow() as Vehicles;

            if (this.SelectObj == null)
                return;
            else
                this.DialogResult = DialogResult.OK;
        }
        



      
    }
}